package com.ruoyi.classinfo.controller;

import com.ruoyi.classinfo.domain.AtVO;
import com.ruoyi.classinfo.service.IAtqkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.neo4j.Neo4jProperties;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/attendance")
public class AtqkController {

    @Autowired
    private IAtqkService attendanceService;

    @GetMapping("/stats")
    public AtVO getAttendanceStats(Authentication authentication) {
        String teacherId = authentication.getName();
        if (teacherId != null && teacherId.startsWith("H")) {
            teacherId = teacherId.substring(1);
        }
        return attendanceService.getAttendanceStats(teacherId);
    }
}
